package com.example.springbootdemo.strategy.optimizeifelse.strategy;

import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：cici
 * @date ：Created in 2019/3/23 14:55
 */
@Slf4j
public class Factory {

    public static Factory factory = new Factory();

    public Factory() {
    }

    private static Map<Integer,DoAccountThing> punishMap = new HashMap<Integer,DoAccountThing>();

    static {
        punishMap.put(UserType.ADMIN.getValue(),new Admin());
        punishMap.put(UserType.AGENT.getValue(),new Agent());
        punishMap.put(UserType.WORKER.getValue(),new Worker());
    }

    public DoAccountThing creator(Integer type){
        return punishMap.get(type);
    }

    public static Factory getInstance(){
        return factory;
    }
}
